<template>
    <div class="regist">
        <van-divider dashed :style="{ color: 'black', borderColor: '#879ac1', padding: '0 16px' ,fontSize:'37px'}">
           欢迎注册
        </van-divider>
        <!-- <mt-field label="手机号：" placeholder="输入手机号" type="number" v-model="phone"></mt-field>
        <mt-field label="密码：" placeholder="输入密码" type="password" v-model="password"></mt-field>
        <mt-button size="large" type="primary" @click="register()">注册</mt-button>
        <mt-button size="large" type="danger" @click="login()">去登录</mt-button>--->

         <van-form @submit="onSubmit" >
  <van-field
    v-model="phone"
    name="用户名"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' },
    { pattern: /^1[356789]\d{9}$/,message: '手机号格式有误'}]"
  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit">注册</van-button>
  </div>
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit" @click="login()">去登陆</van-button>
  </div>
</van-form>
    </div>
</template>
<script>
import Url from '../tools/Url'
import { Toast } from 'mint-ui';
export default {
    name:"Regist",
    data(){
        return{
            phone: "",
            password:"",

        }
    },
    methods:{
        login(){
            this.$router.push("/rester");
        },
        onSubmit() {
               
            var str = `phone=${this.phone}&password=${this.password}`;
           this.axios.post(Url.REGITSTER_URL,str).then(res=>{
               console.log(res);
               if(res.data.code==200){
                    this.$router.push("/rester");
                   Toast(res.data.message);
               }else{
                   Toast(res.data.message);
               }
           })

           
        }
    
    }
    
}
</script>
<style scoped>
.regist{
    width: 100%;
    height: 100%;
    position: fixed;
    background-color:  #fbfef9!important ;
    
}
.van-cell{
    background-color:#fbfef9!important ;
}
</style>